package com.imut.oa.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imut.oa.annotation.AutoFill;
import com.imut.oa.contant.OperationType;
import com.imut.oa.pojo.dto.LeavePageQueryDTO;
import com.imut.oa.pojo.dto.CommonUserPageQueryDTO;
import com.imut.oa.pojo.entity.Leave;
import com.imut.oa.pojo.vo.LeaveVO;
import org.springframework.data.repository.query.Param;

import java.time.LocalDate;


public interface LeaveMapper extends BaseMapper<Leave> {
    /**
     * 分页查询请假数据
     * @param page
     * @param dto
     * @return
     */
    Page<LeaveVO> selectLeavePage(
            Page<LeaveVO> page,
            @Param("dto") LeavePageQueryDTO dto
    );

    /**
     * 分页查询请假数据
     * @param page
     * @param dto
     * @return
     */
    Page<LeaveVO> selectUserLeavePage(
            Page<LeaveVO> page,
            @Param("dto") CommonUserPageQueryDTO dto
    );
    /**
     * 更新请假数据
     * @param leave
     */
    void updateLeave(Leave build);
    /**
     * 插入请假数据
     * @param leave
     */
    @AutoFill(OperationType.INSERT)
    void insertLeave(Leave leave);

    //检查当天是否有该用户处于审核中的请假记录
    boolean existsPendingLeaveByUserAndDate(@Param("employeeId") Long employeeId, @Param("startDate")
    LocalDate startDate);
    /**
     * 判断用户今天是否请假
     * @param employeeId
     * @param
     * @return
     */
    boolean checkIsLeaveToday(@Param("employeeId") Long employeeId, @Param("day") String day);
}
